package cn.itsource.controller;

import cn.hutool.core.util.IdUtil;
import cn.itsource.pojo.domain.DriverPoint;
import cn.itsource.result.JSONResult;
import cn.itsource.service.IDriverPointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
public class DriverPointController {

    @Autowired
    private IDriverPointService driverPointService;

    //保存坐标
    @PostMapping("/point/save")
    public JSONResult savePoint(@RequestBody @Valid DriverPoint point) {
        //使用雪花算法生产ID
        Long id = IdUtil.createSnowflake(1, 1).nextId();
        point.setId(id);
        driverPointService.save(point);
        return JSONResult.success();
    }
}
